package com.lhb.controller;

import com.lhb.pojo.BaseResp;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.naming.AuthenticationException;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.10.14 下午 19:34
 */
@ControllerAdvice
@ResponseBody
public class ExceptionController {

    //没有登陆
    @ExceptionHandler(AuthenticationException.class)
    public BaseResp noLogin() {
        return new BaseResp(1, "该用户没有登录", null, null);
    }

    //没权限
    @ExceptionHandler(AuthorizationException.class)
    public BaseResp auth() {
        return new BaseResp(1, "对不起,您没有权限访问", null, null);
    }
}
